home *** CD-ROM | disk | FTP | other *** search
- Path: news.compuserve.com!newsmaster
- From: Philippe Verdy <100105.3120@compuserve.com>
- Newsgroups: comp.lang.c++
- Subject: Re: HELP: Getting the address of member functions
- Date: 2 Apr 1996 00:23:43 GMT
- Organization: CompuServe Incorporated
- Message-ID: <4jps2f$lhj@dub-news-svc-6.compuserve.com>
- NNTP-Posting-Host: ad15-078.compuserve.com
-
- 079519@bud.swin.edu.au (John Joseph Newbigin) s'Θcrit :
- > I am writing a serial port driver class in BC3.1. It is interrupt driven so I
- > need an interrupt function that can be set to the required int. vector. I can do
- > this using a normal function but it can not access the class data and so needs
- > global vars. and hence, defeats the purpose of a class.
- >
- > Does anyone know how to get the address of member functions so I can overcome this
- > problem?
- >
- >
- > --
- >
- Your interrupt function has to be static !
- This is because a non-static member function has an implicit
- and hidden argument which is the reference to the instance
- object on which the member function applies.
- And interrupt functions do not have parameters (except
- processor registers which have no type).
- So your interrupt function must access to at least one
- static object to find the reference to the data it needs
- to manage.
- I suggest that you build a standard class with only static
- member functions, and a unique data member, which would
- be of class type. Then create a static global pointer or
- object of this class to receive the instance which contains
- interrupt context data.
- Your static member interrupt function will use this static
- object to find access to any non static object to use...
-